Skip to content

test(coverage/nats): drive queueprovider/nats to 100% (was 80.4%)#29

Merged
mastermanas805 merged 1 commit into
masterfrom
coverage/nats-95
May 21, 2026
Merged

test(coverage/nats): drive queueprovider/nats to 100% (was 80.4%)#29
mastermanas805 merged 1 commit into
masterfrom
coverage/nats-95

Conversation

@mastermanas805
Copy link
Copy Markdown
Member

Summary

  • Drives common/queueprovider/nats line coverage from 80.4% → 100.0% (all 14 functions in nats.go).
  • Adds 28 targeted unit tests covering every error branch: builder() bad/missing operator seed and opKP.PublicKey() fail, IssueTenantCredentials's nkeys.* / jwt.* error paths (createAccount/User/PublicKey/Seed, account JWT encode, user JWT encode, FormatUserConfig), RevokeTenantCredentials's empty-keyID / legacy-open / cache-miss / encode-fail / push-fail paths, RevokeWithSeed's empty/legacy/invalid-seed / PublicKey-fail / Encode-fail / push-fail paths, lookupCachedByPub's continue-scanning branch, SetResolverPusher(nil) reset, Capabilities/Name shape, useTLS scheme flip, and canonicalSubject auto-derivation.
  • Minimal source refactor: 4 package-level test seams (createAccountKP, createUserKP, formatUserCreds, parseOperatorKP) so unit tests can inject failing implementations for branches the real nkeys/jwt libraries never trip in practice. Production behavior unchanged — seams alias upstream constructors 1:1.

Test plan

  • go test ./queueprovider/nats -coverprofile=/tmp/c.out → 100.0% of statements
  • go tool cover -func=/tmp/c.out → every function at 100%
  • go test ./queueprovider/nats -count=2 -race → green
  • go vet ./... clean
  • Whole-module go test ./... green (16 packages)

🤖 Generated with Claude Code

Adds targeted coverage for every error branch in queueprovider/nats:

* builder() — bad operator seed, opKP.PublicKey() fail, all defaults applied,
  UseTLS scheme flip
* SetResolverPusher — nil-arg resets to no-op (previously could nil-deref)
* IssueTenantCredentials — empty ResourceToken validation, SystemAccount
  rejection, legacy_open short-circuit when operator seed unset, pusher-error
  propagation, every nkeys.* / jwt.* post-create error branch
  (createAccount/PublicKey/Seed, createUser/PublicKey/Seed, sign account JWT,
  sign user JWT, FormatUserConfig)
* RevokeTenantCredentials — empty keyID no-op, legacy_open no-op, cache-miss
  no-op, encode-revocation failure, push-failure propagation
* RevokeWithSeed — empty seed no-op, legacy_open no-op, FromSeed failure,
  derived public key failure, encode failure, push-failure propagation
* lookupCachedByPub — non-matching entry continue-scanning branch
* connectionURL — useTLS=true tls:// scheme
* Name — "nats" identifier
* Capabilities — full shape (PerTenantAccounts/SubjectScopedAuth/StreamIso=true,
  BasicAuth=false)
* canonicalSubject — auto-derive when Subject empty

Source refactor: 4 package-level test seams (createAccountKP, createUserKP,
formatUserCreds, parseOperatorKP) so unit tests can inject failing
implementations for branches that the real nkeys/jwt libraries never trip in
practice. In production these seams alias the upstream constructors 1:1 —
zero behavior change.

Coverage: 80.4% → 100.0% (all 14 functions in nats.go).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@mastermanas805 mastermanas805 merged commit b974e21 into master May 21, 2026
9 checks passed
@mastermanas805 mastermanas805 deleted the coverage/nats-95 branch May 21, 2026 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant